//
//  CZQDiscoverController.m
//  weibo
//
//  Created by Apple on 15-1-29.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "CZQDiscoverController.h"
#import "CZQSearchBar.h"
@interface CZQDiscoverController ()<UITextFieldDelegate>
/**
 *  搜索框
 */
@property (nonatomic,weak)CZQSearchBar *searchBar;
@end

@implementation CZQDiscoverController

- (void)viewDidLoad
{
    [super viewDidLoad];
    CZQSearchBar *searchBar = [[CZQSearchBar alloc] init];
    searchBar.frame = CGRectMake(100, 100, 280, 30);
    self.navigationItem.titleView = searchBar;
    searchBar.delegate = self;
    self.searchBar = searchBar;
}

#pragma mark UITextFieldDelegate代理方法
- (void)textFieldDidBeginEditing:(UITextField *)textField{

    
    
    //添加按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancle)];
    self.searchBar.leftIconName = @"settings_statistic_triangle";
}

- (void)cancle{
    
    self.navigationItem.leftBarButtonItem = nil;
    
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
    
    self.searchBar.LeftIconName =  @"searchbar_searchlist_search_icon";


}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    [[UIApplication sharedApplication].keyWindow endEditing:YES];
      self.navigationItem.rightBarButtonItem = nil;
    [self cancle];

}
@end
